home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Utilities / ScanTrax / archiv / ScanTrax.lha / Example.rexx next >
OS/2 REXX Batch file  |  1998-06-07  |  8KB  |  316 lines

  1. /*
  2. <Example ARexx-Script for ScanTraxV2.0>
  3.  <ScanTrax is © by Klaus Krause 1998>
  4.  
  5. --------------------------------------------------------------------------------
  6. Important change since ScanTrax V2.0:
  7. Two ARexx commands are need now a special handling: SCAN & SAVE_PICTURE
  8. Since 2.0 you will get back the control immediately after command call.
  9.  
  10. First: To get no problems you must insure that ScanTrax is not busy!
  11. Use GET_REXX_STATUS to get the ScanTrax status condition.
  12.  
  13. Second: If you initialize a scan, you must know when the scan has finished.
  14. Use GET_REXX_STATUS again, to get the ScanTrax status condition.
  15.  
  16. This command should be periodically called, until a 'READY' status was returned.
  17. To waste no CPU time, you should use this command only about every 0.5 second.
  18.  
  19. This was realised with the DOS function 'Delay()' which is included
  20. in the 'rexxsupport.library'.
  21. After a 'GET_REXX_STATUS' call, you should call this Delay function.
  22. The delay function will put your RexxTask into sleep mode until waiting time
  23. has elapsed. While in sleep modetime, other tasks will have the full CPU power!
  24.  
  25. In this example a set of subfunctions are used, which will do ALL necassary
  26. steps for you.
  27.  
  28. The following subfunctions are used:
  29. OpenRexxSupport()  -> Insert the library into the library-list
  30. ScanPicture()      -> Scan data into a tempfile
  31. Savepicture()      -> Convert data of tempfile into a real picture
  32. CloseRexxSupport() -> Remove the library from the library-list
  33.  
  34. To use these functions in your own project, simply add the functionblock
  35. at the end of this example to your ARexx-Script and watch this example how
  36. to use these.
  37. --------------------------------------------------------------------------------
  38. */
  39.  
  40.  
  41. OPTIONS RESULTS
  42.  
  43. ADDRESS "SCANTRAX"
  44.  
  45. CALL OpenRexxSupport() /*Insert Library into list {get access to Delay()} */
  46.  
  47.  
  48.  
  49.  
  50. say "ScanTrax ARexx Demonstration:"
  51.  
  52. GET_REXX_VERSION
  53. say " Rexx Version   = " RESULT
  54. say
  55. say
  56. /* "To insure that you have the only access to ScanTrax,"
  57.    "you must lock the User-Interface. Otherwise the user can"
  58.    "disturb your project..."
  59. */
  60. DISPLAY_LOCK
  61.  
  62. say "A look at the current ARexx-picture-setup:"
  63. GET_INTENSITY
  64. say " Intensity   = " RESULT "%"
  65. GET_CONTRAST
  66. say " Contrast    = " RESULT "%"
  67. GET_COLOR_RED
  68. say " Color Red   = " RESULT "%"
  69. GET_COLOR_GREEN
  70. say " Color Green = " RESULT "%"
  71. GET_COLOR_BLUE
  72. say " Color Blue  = " RESULT "%"
  73. GET_SHARPEN
  74. say " Sharpen     = " RESULT "%"
  75. GET_GAMMA
  76. say " Gamma       = " RESULT
  77. GET_JPEG_QUALITY
  78. say " JPEG-Quality= " RESULT
  79. say
  80.  
  81. say "------------------------------------------------------------"
  82. say
  83. say "Short example for setting the graphic mode:"
  84. say
  85. say "Adjusting the graphic-mode to BlackWhite Treshold."
  86. SET_GFX_MODE BLACKWHITE
  87. GET_GFX_MODE
  88. say " ( This mode has the internal number: " RESULT ")"
  89. say
  90. say "Adjusting the graphic-mode to 8bit GreyScale."
  91. SET_GFX_MODE GREYSCALE
  92. GET_GFX_MODE
  93. say " ( This mode has the internal number: " RESULT ")"
  94. say
  95. say "Adjusting the graphic-mode to number 2."
  96. SET_GFX_MODE NUMBER 2
  97. GET_GFX_MODE
  98. say " ( Mode changes to internal number: " RESULT ")"
  99. say
  100. say "You want finally scan in 24bit color."
  101. SET_GFX_MODE COLOR
  102. GET_GFX_MODE
  103. say " ( This mode has the internal number: " RESULT ")"
  104. say
  105.  
  106. say "------------------------------------------------------------"
  107. say
  108. say "You enable filename-suffixes."
  109. SET_SUFFIX_MODE 1
  110. GET_SUFFIX_MODE
  111. say " ( Current filename-suffix logical status is now: " RESULT ")"
  112. say
  113. say "Setting intensity to 0 %"
  114. SET_INTENSITY '0'
  115. say
  116. say "Setting contrast  to 14 %"
  117. SET_CONTRAST '14'
  118. say
  119. say "Setting sharpness to 50 %"
  120. SET_SHARPEN '50'
  121. say
  122. say "Setting gamma     to 2.20"
  123. SET_GAMMA '2.2'
  124. say
  125.  
  126. GET_RESOLUTION XMIN
  127. x_min = RESULT
  128. GET_RESOLUTION XMAX
  129. x_max = RESULT
  130. say "Your horizontal resolution range is "x_min" to "x_max" dpi!"
  131. GET_RESOLUTION YMIN
  132. y_min = RESULT
  133. GET_RESOLUTION YMAX
  134. y_max = RESULT
  135. say "Your vertical resolution range is "y_min" to "y_max" dpi!"
  136. say
  137.  
  138. say "Setting scan resolution to 75 x 75 dpi."
  139. SET_RESOLUTION 75 75
  140. say
  141.  
  142. GET_SCALE XMIN
  143. x_min = RESULT
  144. GET_SCALE XMAX
  145. x_max = RESULT
  146. say "Your horizontal scaling range is "x_min" to "x_max" %!"
  147. GET_SCALE YMIN
  148. y_min = RESULT
  149. GET_SCALE YMAX
  150. y_max = RESULT
  151. say "Your vertical scaling range is "y_min" to "y_max" %!"
  152. say
  153.  
  154. say "Setting a 100 x 100 % Scale."
  155. SET_SCALE 100 100
  156. say
  157.  
  158. say
  159. say "Setting centimeters as input unit for length values."
  160. SET_MEASUREUNIT CM
  161. say
  162. GET_WINDOW XMAX
  163. x_max = RESULT
  164. GET_WINDOW YMAX
  165. y_max = RESULT
  166. say "Your maximal flatbed scanarea is "x_max" x "y_max" cm!"
  167. say
  168. say "Setting your ScanWindow to: 12.5 x 8 cm in Size, with an 5 x 5 cm Offset."
  169. SET_WINDOW 5 5 12.5 8
  170.  
  171.  
  172. SET_PROGRESSBAR_MODE 1 /*Enable a progress bar!*/
  173.  
  174. say "Now you are ready to start a scan, scanning into tempfile...."
  175. success = ScanPicture()
  176. IF success = 1
  177.  THEN say "Your scan was successful :-)"
  178.  ELSE DO /*Error: The script ends at this point*/
  179.     IF success = -1 THEN say "Last command was aborted :-("
  180.    IF success = 0 THEN say "An error has occured with last command :-("
  181.     DISPLAY_UNLOCK
  182.     CALL CloseRexxSupport()
  183.     EXIT 10
  184.  END
  185.  
  186. say
  187. say
  188. say "|---PNG-EXAMPLE---------------------------------------------"
  189. say "|Create an Icon for this and all following pictures:"
  190. SET_ICON_MODE 1
  191. GET_ICON_MODE
  192. say "| ( Icon-Creation was set to logical number: " RESULT ")"
  193. say "|Selecting a fast PNG compressionrate..."
  194. SET_PNG_COMPRESSION 3
  195. say "|Writing a PiNG picture to ram:Testpicture..."
  196. success = SavePicture(PNG 'RAM:Testpicture')
  197. say "|Logical result of write: " success
  198. say
  199.  
  200. say "|---JPEG-EXAMPLE--------------------------------------------"
  201. say "|Setting JPG Quality to 45"
  202. SET_JPEG_QUALITY 45
  203. say "|Writing a JPEG picture to ram:Testpicture..."
  204. success = SavePicture(JPEG 'RAM:Testpicture')
  205. say "|Logical result of write: " success
  206. say
  207.  
  208. say "|---TARGA-EXAMPLE-------------------------------------------"
  209. say "|Writing a TARGA picture to ram:Testpicture..."
  210. success = SavePicture(TARGA 'RAM:Testpicture')
  211. say "|Logical result of write: " success
  212. say
  213.  
  214. say "|---DEEP-EXAMPLE--------------------------------------------"
  215. say "|Writing a IFF-DEEP picture to ram:Testpicture..."
  216. success = SavePicture(DEEP 'RAM:Testpicture')
  217. say "|Logical result of write: " success
  218. say
  219.  
  220. say "|---ILBM-EXAMPLE--------------------------------------------"
  221. say "|Switching IFF-ILBM compression to ON"
  222. SET_ILBM_COMPRESSION 1
  223. say "|Writing a IFF-ILBM picture to ram:Testpicture..."
  224. success = SavePicture(ILBM 'RAM:Testpicture')
  225. say "|Logical result of write: " success
  226. say
  227.  
  228. say "|---JPEG-EXAMPLE-(a-background-write)-----------------------"
  229. SET_PROGRESSBAR_MODE 0
  230. SET_ICON_MODE 0
  231. say "|Setting JPG Quality to 5"
  232. SET_JPEG_QUALITY 5
  233. say "|Writing a JPEG picture to ram:Testpicture..."
  234. success = SavePicture(JPEG 'RAM:TestpictureSecret')
  235. say "|Logical result of write: " success
  236. say
  237.  
  238.  
  239.  
  240. /*---SHUT-DOWN---*/
  241. DISPLAY_UNLOCK          /*UnLock the User-Interface*/
  242. CALL CloseRexxSupport() /*Remove Library from list */
  243.  
  244.  
  245.  
  246.  
  247.  
  248. say "-EXAMPLE-RESULTS-------------------------------------------"
  249. say "Looking into the RamDisk for your pictures:"
  250. ADDRESS COMMAND "C:list ram:Testpicture#?"
  251. say
  252. say "ARexx example has finished. Thanks for watching this :-)"
  253.  
  254. EXIT 0 /* END OF EXAMPLE SCRIPT */
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263. /*-------------------SUB-FUNCTION-BLOCK---------------------*/
  264.  
  265. OpenRexxSupport:
  266.     IF ~SHOW('L', "rexxsupport.library") THEN
  267.         IF ~ADDLIB('rexxsupport.library', 0, -30,0) THEN EXIT 10
  268.     return 1
  269. /* END of OpenRexxSupport() */
  270.  
  271. CloseRexxSupport:
  272.     return REMLIB('rexxsupport.library')
  273. /* END of CloseRexxSupport() */
  274.  
  275. WaitUntilReady:
  276.     DO FOREVER
  277.         GET_STATUS
  278.         IF RC ~= 0 THEN return 0
  279.         IF RESULT = 'READY' THEN return 1
  280.         call delay(25)
  281.     END
  282. /* END of WaitUntilReady() */
  283.  
  284. ScanPicture:
  285.     CALL WaitUntilReady()
  286.     SCAN
  287.     IF RC ~= 0 THEN return 0
  288.  
  289.     DO FOREVER
  290.         call delay(25)
  291.  
  292.         GET_STATUS
  293.         IF RC ~= 0 THEN return 0
  294.         IF RESULT = 'READY' THEN return 1
  295.         IF RESULT = 'ABORT' THEN return -1
  296.     END
  297. /* END of ScanPicture() */
  298.  
  299. SavePicture:
  300.     parse arg keyword1 name1
  301.     CALL WaitUntilReady()
  302.     SAVE_PICTURE strip(keyword1) strip(name1)
  303.     IF RC ~= 0 THEN return 0
  304.  
  305.     DO FOREVER
  306.         call delay(25)
  307.  
  308.         GET_STATUS
  309.         IF RC ~= 0 THEN return 0
  310.         IF RESULT = 'READY' THEN return 1
  311.         IF RESULT = 'ABORT' THEN return -1
  312.     END
  313. /* END of ScanPicture() */
  314.  
  315. /*--END-OF-----------SUB-FUNCTION-BLOCK---------------------*/
  316.